package com.yilin.medical.utils;

import java.util.HashMap;

import android.content.Context;
import android.view.View;
import android.view.WindowManager;

public class JxMeasureUtils {
	public static int customMeasureWidth(View view) {
		try {
			int w = View.MeasureSpec.makeMeasureSpec(0,
					View.MeasureSpec.UNSPECIFIED);
			int h = View.MeasureSpec.makeMeasureSpec(0,
					View.MeasureSpec.UNSPECIFIED);
			view.measure(w, h);
			int width = view.getMeasuredWidth();
			return width;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return 0;
	}

	public static int customMeasureHeight(View view) {
		try {
			int w = View.MeasureSpec.makeMeasureSpec(0,
					View.MeasureSpec.UNSPECIFIED);
			int h = View.MeasureSpec.makeMeasureSpec(0,
					View.MeasureSpec.UNSPECIFIED);
			view.measure(w, h);
			int height = view.getMeasuredHeight();
			// int width =mAbTitleBar.getMeasuredWidth();
			return height;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return 0;
	}

	public static int dip2px(Context context, float dpValue) {
		final float scale = context.getResources().getDisplayMetrics().density;
		return (int) (dpValue * scale + 0.5f);
	}

	public static int getwidth(Context content) {
		WindowManager wm = (WindowManager) content
				.getSystemService(Context.WINDOW_SERVICE);
		int width = wm.getDefaultDisplay().getWidth();
		return width;

	}

	public static int getheight(Context content) {
		WindowManager wm = (WindowManager) content
				.getSystemService(Context.WINDOW_SERVICE);
		int height = wm.getDefaultDisplay().getHeight();
		return height;

	}



}
